import { HealthCheckWithScreenTask } from "./health.check.class";
import { ScanBoardKey, V3proSubjectMessage } from "../model/v3pro.model";
import { V3proScreen, V3proScreenAllStatus } from "../../../api/v3pro-api/v3pro.api.response.model";
import { V3proAlertMessageErrTypeEnum } from "../model/v3pro.enum";
import { V3proScreenLayoutHelper } from "../helper/v3pro.screen.layout.helper";
import { appConfig } from "../../../configs/env.config.load";

/**
 * 扫描板网络误码率过高
 *
 * 是否支持阈值设置： N
 *
 * 查询周期:
 * 由扫描板主动上报
 *
 * 告警产生的原因:
 * 扫描板或转接板元器件自身问题
 * 网线质量问题或接触不良
 *
 * 异常现象:
 * 机箱显示画面出现抖动或卡顿
 * 机箱显示画面随机出现亮线闪烁
 *
 * 维修建议:
 * 依次排查网线、转接板、扫描板等硬件
 *
 * 告警级别: 次要
 */
export class V3proCheckScanboardNetworkErrorBitTask extends HealthCheckWithScreenTask<
  ScanBoardKey[]
> {
  async checkResult(
    keyParams: ScanBoardKey[],
    screenId: string,
    allStatus: V3proScreenAllStatus,
    screenLayoutHelper: V3proScreenLayoutHelper,
  ): Promise<V3proSubjectMessage> {
    return new V3proSubjectMessage();
  }

  async genKeyParams(
    allStatus: V3proScreenAllStatus,
    screen: V3proScreen,
    screenLayoutHelper: V3proScreenLayoutHelper,
  ): Promise<ScanBoardKey[]> {
    // TODO 判断规则不明确
    return [];
  }

  genSRMqttTopic(
    message: V3proSubjectMessage,
    screenId: string,
    allStatus: V3proScreenAllStatus,
  ): string {
    return `notify/alert/ssads/device-common:ber-over-limit/${screenId}`;
  }

  getV3proAlertMessage(): V3proAlertMessageErrTypeEnum {
    return V3proAlertMessageErrTypeEnum.SCAN_BOARD_NETWORK_ERROR_BIT;
  }

  isNeedUploadFile(
    message: V3proSubjectMessage,
    screenId: string,
    allStatus: V3proScreenAllStatus,
  ): boolean {
    return message.isErrStatus();
  }

  isReportEnabled(keyParams: any, screenId: string): boolean {
    return appConfig.v3pro.errEnable.scanBoardErrBitRate;
  }
}
